/*
	NounEnhancement.h
	(c)2008 Palestar Inc, Jeff Everett
*/



#ifndef NOUNENHANCEMENT_H
#define NOUNENHANCEMENT_H

class NounShip;

class DLL NounEnhancement : public NounGame
{
public:
	DECLARE_WIDGET_CLASS();
	DECLARE_PROPERTY_LIST();

	NounEnhancement(){};

	// each enhancement has 3 things
	//	the amout of modification (1-5 currently)
	//	the system modified (one of the EF flags below)
	//  and the type of modification (lowered cooldown, increase damage, etc)
	//	as an additional enhancement to this system, we could add additional enhancements per nounenhancement


	// Types
	enum System 
	{
		ES_NONE = -1,
		ES_BEAM,
		ES_ARMOR,
		ES_AUTOREPAIR,		
		ES_BUILD,			
		ES_CLOAK,			
		ES_DRIVE,			
		ES_ECCM,			
		ES_ECM,				
		ES_FIGHTERS,			
		ES_JUMPDRIVE,		
		ES_JUMPGATE,			
		ES_MINING,			
		ES_PULSESHIELD,		
		ES_REACTOR,			
		ES_RELOAD,			
		ES_SCANNER,			
		ES_SHIELD,			
		ES_TRACTOR,			
		ES_WEAPON,	
		ES_VELOCITY,
		ES_THRUST,
		ES_TURNRATE,
		ES_SHIPENERGY,
		ES_TRAIL,
		ES_DEFENSE,

		ES_SYSTEMCOUNT
	};

	enum ModifierType
	{
		MT_RANGE,		// change range
		MT_COOLDOWN,	// change cooldown
		MT_DAMAGE,		// chage damage
		MT_ENERGY,		// change energy
		MT_INCREASE,	// add
		MT_REFILL,		// resets a value
		MT_APPLY,		// applys a value, like setting a material

		MT_MODIFIERCOUNT
	};

	enum ApplyType
	{
		AT_ATTACH,
		AT_USE
	};

	enum RequirementFlag 
	{
		REQ_SUBSCRIBER				= 0x00000001,	


		REQ_ENGINEER				= 0x00000100,					
		REQ_SUPPLY					= 0x00000200,					
		REQ_TRANSPORT				= 0x00000400,					
		REQ_SCOUT					= 0x00000800,					
		REQ_FRIGATE					= 0x00001000,					
		REQ_DESTROYER				= 0x00002000,					
		REQ_CRUISER					= 0x00004000,					
		REQ_DREAD					= 0x00008000,					
		REQ_STATION					= 0x00010000,

		REQ_ADMIN					= 0x10000000,

		REQ_ANY						= REQ_ENGINEER|REQ_SUPPLY|REQ_TRANSPORT|REQ_SCOUT|REQ_FRIGATE|REQ_DESTROYER|REQ_CRUISER|REQ_DREAD|REQ_STATION,
	};

	enum TrailColors
	{
		TRAIL_PURPLE				= 0,
		TRAIL_GREEN					= 1,
		TRAIL_RED					= 2,
		TRAIL_BLUE					= 3,
	};

	enum Rarity
	{
		RARITY_COMMON		= 1,
		RARITY_RARE			= 2,
		RARITY_ULTRA_RARE	= 3,
	};

	typedef WidgetReference< NounEnhancement >	wRef;
	typedef Reference<NounEnhancement>	Ref;

	//! Widget interface
	bool						read( InStream & );
	//! Noun interface
	NounType					nounType() const;

	//! Accessors
	int							enhancementCount() const;
	Material *					icon() const;
	Color						color() const;
	CharString					status() const;	// status string

	System						GetSystem(int a_index) const;
	ModifierType				GetModifier(int a_index) const;
	int							GetAmount(int a_index) const;
	CharString					GetDescription() const;

	bool						canApply(NounShip *a_pShip) const;

	//! Interface
	virtual dword				requirementFlags() const;
	virtual Rarity				rarity()  const;
	virtual bool				IsUnique() const;

	virtual void				onUse( NounShip *a_pShip );

	bool						enhanceJumpDrive(NounShip *a_pShip, int a_index);
	bool						enhanceShipEnergy(NounShip *a_pShip, int a_index);
	bool						testFlags( dword test ) const;

	virtual CharString			GetName() const = 0;
	virtual ApplyType			applyType() const = 0;

	//! Static
	static CharString			GetInfo(NounEnhancement::System a_system, NounEnhancement::ModifierType a_modifier);
	static void					InitializeIcons();

	static Material::Link		m_Icons[System::ES_SYSTEMCOUNT][ModifierType::MT_MODIFIERCOUNT];
	static bool					m_bInitialized;


protected:
	struct Enhancement : public Referenced
	{
		typedef Reference< Enhancement >		Ref;
		Enhancement(System a_system, ModifierType a_modifier, int a_amount);

		System			m_System;
		ModifierType	m_Modifier;
		int				m_Amount;
	};


	std::vector<Enhancement::Ref>	
								m_enhancements;

};

#endif

